#!/bin/bash

## date: 2025-0821

top_name=$1
date=$(date +%y%m%d)
path="/projects.SE032/cascade/workspace/xwqiu/PV/v2lvs"

netlist="/projects.SE032/cascade/workspace/xwqiu/${top_name}/post.${date}/dataout/${top_name}.strm.${date}.lvs.v.gz"
#top_name=$(/apps/mentor/aoi_cal_2018.4_17.10/bin/python3 /projects.SE024/cascade/workspace/xjsun/PV/v2lvs/get_top_name.py ${netlist})
#echo ${top_name}
outfile="${path}/${top_name}.spi"


v2lvs -v ${netlist} -o ${outfile}

cdl_path="/projects/cascade/workspace/xwqiu/DDRPHY/datain/IP/netlist"

if [ ${top_name} == "DDR_WRITE_READ_H" ] ; then
echo ".include ${cdl_path}/dll_fine.netlist" >> ${outfile}
echo ".include ${cdl_path}/DLY_LINE_512.netlist" >> ${outfile}
echo ".include ${cdl_path}/DOUBLE_EDGE_FF_pdata.netlist" >> ${outfile}
echo ".include ${cdl_path}/DOUBLE_EDGE_FF_ndata.netlist" >> ${outfile}
fi

if [ ${top_name} == "DLL_DDR_V" ] ; then
echo ".include ${cdl_path}/DLY_LINE_1024.netlist" >> ${outfile}
echo ".include ${cdl_path}/DLY_LINE_1024_MAT.netlist" >> ${outfile}
echo ".include ${cdl_path}/MARS_DLL_ARB.netlist" >> ${outfile}
fi

#### pdk stdcell ####
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_base_lvt_100a/tcbn06_bwph240l11p57cpd_base_lvt_100a.spi" >> ${outfile} 
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_base_svt_100a/tcbn06_bwph240l11p57cpd_base_svt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_base_ulvt_100a/tcbn06_bwph240l11p57cpd_base_ulvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_lvl_lvt_100a/tcbn06_bwph240l11p57cpd_lvl_lvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_lvl_svt_100a/tcbn06_bwph240l11p57cpd_lvl_svt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_lvl_ulvt_100a/tcbn06_bwph240l11p57cpd_lvl_ulvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_mb_lvt_100a/tcbn06_bwph240l11p57cpd_mb_lvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_mb_svt_100a/tcbn06_bwph240l11p57cpd_mb_svt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_mb_ulvt_100a/tcbn06_bwph240l11p57cpd_mb_ulvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_pm_lvt_100a/tcbn06_bwph240l11p57cpd_pm_lvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_pm_svt_100a/tcbn06_bwph240l11p57cpd_pm_svt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l11p57cpd_pm_ulvt_100a/tcbn06_bwph240l11p57cpd_pm_ulvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_base_lvt_100a/tcbn06_bwph240l8p57cpd_base_lvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_base_svt_100a/tcbn06_bwph240l8p57cpd_base_svt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_base_ulvt_100a/tcbn06_bwph240l8p57cpd_base_ulvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_lvl_lvt_100a/tcbn06_bwph240l8p57cpd_lvl_lvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_lvl_svt_100a/tcbn06_bwph240l8p57cpd_lvl_svt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_lvl_ulvt_100a/tcbn06_bwph240l8p57cpd_lvl_ulvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_mb_lvt_100a/tcbn06_bwph240l8p57cpd_mb_lvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_mb_svt_100a/tcbn06_bwph240l8p57cpd_mb_svt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_mb_ulvt_100a/tcbn06_bwph240l8p57cpd_mb_ulvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_pm_lvt_100a/tcbn06_bwph240l8p57cpd_pm_lvt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_pm_svt_100a/tcbn06_bwph240l8p57cpd_pm_svt_100a.spi" >> ${outfile}
echo  ".include /pdks/tsmc/CLN06FF/std/TSMCHOME/digital/Back_End/spice/tcbn06_bwph240l8p57cpd_pm_ulvt_100a/tcbn06_bwph240l8p57cpd_pm_ulvt_100a.spi" >> ${outfile}